package zeebe.multiInstance;

import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.response.DeploymentEvent;

public class MultiParallelDeploy {
    public static void main(String[] args) {
        System.out.println("创建Zeebe的连接");
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("部署工作流");
        String bpmnPath = "bpmn/multiParallel.bpmn";
        DeploymentEvent deployment = client.newDeployCommand()
                .addResourceFromClasspath(bpmnPath)
                .send()
                .join();

        System.out.println("部署multiParallelJobWorker");
        String inputType = "parallelA";
        MultiParallelJobWorkerHandler multiJobWorkerHandler = new MultiParallelJobWorkerHandler(client);
        client.newWorker()
                .jobType(inputType)
                .handler(multiJobWorkerHandler)
                .open();

        System.out.println("部署printJobWorker");
        String printType = "print";
        PrintJobWorkerHandler printJobWorkerHandler = new PrintJobWorkerHandler(client);
        client.newWorker()
                .jobType(printType)
                .handler(printJobWorkerHandler)
                .open();
    }
}
